package com.vidyu.datalayer.dataaccesscomponents.impl;

import com.vidyu.businesslayer.businessentities.MonitorEvent;
import com.vidyu.datalayer.dataaccesscomponents.MonitorDbHandler;
import com.vidyu.datalayer.dataaccesscomponents.MonitorEventDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Calendar;

/**
 * Created by IntelliJ IDEA.
 * User: eyalsa
 * Date: 28/02/12
 * Time: 14:46
 * To change this template use File | Settings | File Templates.
 */
@Component
public class MonitorDbHandlerImpl implements MonitorDbHandler{

    @Autowired
    private MonitorEventDao monitorEventDao;

    public long save(String className, String module, String text) {
        MonitorEvent mv = new MonitorEvent();
        mv.setModule(module);

        mv.setText(text);
        mv.setClassName(className);
        long curTime = Calendar.getInstance().getTimeInMillis();
        mv.setTime(curTime);
        return monitorEventDao.save(mv);
    }

    public MonitorEvent findById(long id){
        return monitorEventDao.findById(id);
    }
}
